package org.dromara.MapData.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil;
import jakarta.annotation.Resource;
import org.dromara.MapData.domain.mapData;
import org.dromara.common.core.domain.R;
import org.dromara.regionData.domain.bo.InsuranceRegionDataBo;
import org.dromara.regionData.domain.vo.InsuranceRegionDataVo;
import org.dromara.regionData.service.IInsuranceRegionDataService;
import org.redisson.api.RList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/mapData/mapData")
public class MapDataController {

    @Resource
    private IInsuranceRegionDataService insuranceRegionDataService;

    @SaCheckPermission("mapData:mapData:list")
    @GetMapping("/list")
    public R<List<mapData>> getMapData(){
        List<InsuranceRegionDataVo> vos = insuranceRegionDataService.queryList(new InsuranceRegionDataBo());
        List<mapData> mapData = BeanUtil.copyToList(vos, mapData.class);
        mapData.forEach(m -> m.setName(m.getRegionName()));
        mapData.forEach(m -> m.setValue(m.getInsuredCount()));
        return R.ok(mapData);
    }
}
